home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / tdir.arc / TD.DOC < prev   
Encoding:
Text File  |  1985-02-15  |  19.8 KB  |  655 lines

  1.                    TD - A Tree Directory Tool
  2.  
  3.  
  4.  
  5.  
  6.                  Copyright 1984 by John Falconer
  7.  
  8.              *** All Commercial Rights Reserved ***
  9.  
  10.  
  11. The  author dedicates this program to the public domain.   It may
  12. be freely distributed and used for non-commercial  purposes.   If
  13. you find personal value in the program you are encouraged to help
  14. defray  the cost of its developement by sending a small contribu-
  15. tion to the author.   Please direct suggestions, bug reports, and
  16. any contributions to:
  17.  
  18.                         John D. Falconer
  19.                         2012 Cambridge Drive
  20.                         Alameda, CA  94501
  21.  
  22.                         (415) 521-7245
  23.                         Compuserve 72435-1617
  24.  
  25.  
  26. The source code for this program was compiled with Borland Inter-
  27. national's  Turbo (TM) Pascal compiler,  with  assembly  language
  28. additions assembled with Microsoft's MASM macro assembler.
  29.  
  30.  
  31. 1.  Overview:
  32.  
  33.   TD  is  a directory listing program with features  designed  to
  34. simplify  the use and cataloging of files stored on MS-DOS or PC-
  35. DOS systems using tree-structured directories.
  36.  
  37.   Features include:
  38.  
  39.      - Access to all directories of a disk
  40.      - All features accessible from the command line
  41.      - Default configuration easily customized by user
  42.      - 3 different basic modes of output:  full, tree, and wide
  43.      - Automatic logging to a directory holding a specified file
  44.      - Return of information to DOS's environment
  45.      - Alphabetic sorting of directories with a common parent
  46.      - Sorting of file entries by name, extension, size, or date
  47.      - Changing or adding volume names
  48.      - Optional display of hidden and system files
  49.      - Optional pause at full screens
  50.      - Output formats for dBASE II and dBASE III
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.                                 1
  62.  
  63.  
  64.  
  65.  
  66.  
  67.                    TD - A Tree Directory Tool
  68.  
  69.  
  70.  
  71.  
  72. 2.  Output Modes:
  73.  
  74.    A.  Full listing (default):
  75.  
  76.      In its default mode,  TD will search all subdirectories of a
  77.    disk  for  files meeting the ambiguous or  unambiguous  drive,
  78.    path,  and file specification given on the command line.   All
  79.    subdirectories  containing  files  matching the  command  line
  80.    specification will be listed in alphabetical order,  with  all
  81.    matching files listed in alphabetical order within each direc-
  82.    tory.   These  listings will be in a fixed-field-length format
  83.    showing the path along which each listed entry was found.  The
  84.    detailed  output of this mode is sent to the  standard  output
  85.    file and may be redirectd.
  86.  
  87.    B.  Pictorial Tree:
  88.  
  89.      An alternative output,  directed only to the console,  will,
  90.    when selected with the "T" switch on the command line,  appear
  91.    as  a graphic "tree",  with the number of matching files found
  92.    in  each  directory indicated within  square  brackets.   This
  93.    "tree"  shows  at a glance the structure of a volume  and  the
  94.    location  of  sought files.   If a color graphics  display  is
  95.    used,  directories  which  contain files matching the  command
  96.    line specification will appear in green, while the others will
  97.    appear  in  yellow.   The currently logged directory  will  be
  98.    marked  with  a pointer which will appear in red  on  a  color
  99.    graphics display.
  100.  
  101.    C.  Wide (abreviated) listing:
  102.  
  103.      Another  alternative output is TD's "wide" listing.  This is
  104.    selected  with  the "W" switch on the command  line.  In  this
  105.    mode,  TD's output will include only the file name and  exten-
  106.    sion  for  every matching file.   Directories will  appear  in
  107.    alphabetical order and the files within each directory will be
  108.    listed  according to the currently selected  sort  mode.   The
  109.    currently logged directory will be marked on the screen with a
  110.    pointer, but this pointer will not be included in the redirec-
  111.    table output.  The detailed output of this mode is sent to the
  112.    standard output device and may be redirected.
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.                                 2
  128.  
  129.  
  130.  
  131.  
  132.  
  133.                    TD - A Tree Directory Tool
  134.  
  135.  
  136.  
  137.  
  138. 3. Options (switch settings on the command line):
  139.  
  140.    A - Add a volume name if none exists
  141.  
  142.      When this option is switched on, TD will prompt for a volume
  143.    name  if no volume name is currently assigned.   This  can  be
  144.    useful when preparing a catalog of diskettes;  most disks will
  145.    probably  already  be labeled and this option will prompt  for
  146.    labels  only for those which are not.   This  option  defaults
  147.    off.
  148.  
  149.  
  150.    B - Batch: return NAM, ERR, SPC, SIZ
  151.  
  152.      When  this option is switched on,  TD will return values  to
  153.    variables maintained in the DOS environment.   This feature is
  154.    meant  to  be especially useful to programmers who are  custo-
  155.    mizing a system with batch files.   For instance,  if a backup
  156.    procedure has been designed using TD's environment  variables,
  157.    it  is  easy to ensure that a user has the backup disk in  the
  158.    right place at the right time,  and that there is enough  room
  159.    on  it to receive the files being transferred.   The variables
  160.    returned by TD are as follows:
  161.  
  162.      NAM will return with the name of the volume.
  163.  
  164.      SPC will return with a string containing the number of free
  165.          bytes on the disk.
  166.  
  167.      SIZ will return with a string containing the number of bytes
  168.          used by files which meet the filespec given to TD.
  169.          ERR will contain a number corresponding to the following
  170.          conditions:
  171.  
  172.          0 .. normal, if a file was sought, it was found
  173.          1 .. no find, couldn't find the specified file
  174.          2 .. unable to log to new directory
  175.          3 .. both of the two preceding
  176.          4 .. drive specified not available.
  177.  
  178.    This option defaults off.
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.                                 3
  193.  
  194.  
  195.  
  196.  
  197.  
  198.                    TD - A Tree Directory Tool
  199.  
  200.  
  201.  
  202.  
  203.      Here is an example which makes use of TD's ability to return
  204.    the  volume  ID's to keep a casual user from making a  mistake
  205.    when backing up an important disk:
  206.  
  207.          rem  BATCH file VOLBACK.BAT
  208.          rem    This file will verify that the user has placed the proper
  209.          rem    volumes in the A: and B: drives for file copying.
  210.          rem
  211.          rem  USE:       volback sourcename destname
  212.          rem
  213.          rem    Where sourcename and destname are volume ID's.
  214.          rem
  215.          echo off
  216.          cls
  217.          echo Please place %1 in A: and %2 in B:
  218.          pause
  219.          :GS
  220.          set VOL=A:
  221.          set MAT=%1
  222.          set FLT=GS
  223.          set RET=GD
  224.          goto SUB
  225.          :GD
  226.          set VOL=B:
  227.          set MAT=%2
  228.          set FLT=GD
  229.          set RET=OKS
  230.          goto SUB
  231.          :OKS
  232.          copy a:*.* b:
  233.          for %%1 in (VOL MAT FLT RET) do set %%1=
  234.          goto end
  235.          rem subroutine here uses TD
  236.          :SUB
  237.          td %VOL%:/bqx
  238.          if %NAM% == %MAT% goto %RET%
  239.          echo The disk in %VOL% is %NAM%, not %MAT%.
  240.          echo Please remove %NAM% and insert %MAT%.
  241.          pause
  242.          goto %FLT%
  243.          :END
  244.          cls
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.                                 4
  259.  
  260.  
  261.  
  262.  
  263.  
  264.                    TD - A Tree Directory Tool
  265.  
  266.  
  267.  
  268.  
  269.    C - Continue until user quits
  270.  
  271.      When this option is switched on,  TD will perform its duties
  272.    on a disk in the default or specified drive,  and then  prompt
  273.    the user to insert another disk,  repeating this process until
  274.    the user indicates a desire to quit.  This is very useful when
  275.    sending listings to a textfile for cataloging purposes.  Cata-
  276.    loging   an  entire library is reduced to the simple  task  of
  277.    removing  and  inserting disks when TD  prompts  (and  beeps).
  278.    This option defaults off.
  279.  
  280.    D, E, N, S - sort by Date, Extension, Name or Size
  281.  
  282.      These options determine the order in which files are  listed
  283.    within each directory.  The date sort is performed so that the
  284.    time  of  file modification is considered in addition  to  the
  285.    date.  The default sorting method is by name.
  286.  
  287.    H - Hidden files
  288.  
  289.      When  this  option is switched on,  TD will list hidden  and
  290.    system files in addition to other files.  This option defaults
  291.    off.
  292.  
  293.    L - Log to directory with match
  294.  
  295.      When  this  option is switched on,  TD will search  for  the
  296.    file(s) matching a filespec, and then log the searched disk to
  297.    the last directory in which a match was found.   This can save
  298.    time  and  typing when working from  the  command  line.   For
  299.    instance,  you may know that WS.COM is a file in the directory
  300.    you  want  to log to on your hard disk,  but not remember  the
  301.    complete path specification to it.   Just type "td ws/ql"  and
  302.    TD  will log in to the directory where "ws" is found (the  "q"
  303.    switch will suppress TD's output,  as explained below).   Used
  304.    in a batch file,  this option can automatically log users into
  305.    subdirectories  appropriate to their work;   without the users
  306.    needing to know what subdirectories are.  This option defaults
  307.    off.
  308.  
  309.    O - Omit volume name
  310.  
  311.      When  this option is switched on,  TD will omit  the  volume
  312.    name  in the detail portion of listings.   When switched  off,
  313.    volume  names  will be appear at the beginning of path  names,
  314.    allowing  the  unique identification of each  file  for  cata-
  315.    loging.  This  option  defaults on unless either of the  dBASE
  316.    options has been switched on.
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.                                 5
  325.  
  326.  
  327.  
  328.  
  329.  
  330.                    TD - A Tree Directory Tool
  331.  
  332.  
  333.  
  334.  
  335.    P - Pause at full screen
  336.  
  337.      When this option is switched on,  TD will pause at each full
  338.    screen  and  display  a  message asking  the  user  to  either
  339.    continue  or  quit.  This option is effective only  with  TD's
  340.    default  (full) and wide listings.    This option defaults  on
  341.    unless either of the dBASE options has been switched on.
  342.  
  343.    Q - Quiet output
  344.  
  345.      When this option is switched on, TD will suppress its output
  346.    to  the screen.   This option is included so that batch  files
  347.    and  other programs may call TD to change directories  or  get
  348.    results  back through the environment variables,  without dis-
  349.    trubing their own screen displays.   This option defaults off.
  350.  
  351.    T - Tree display
  352.  
  353.      When this option is switched on, TD will display a pictorial
  354.    tree on the console.   In this mode each level of a  directory
  355.    structure  will  be listed on one line,  with the  directory's
  356.    name and the number of files in that directory which match the
  357.    filespec  listed next to the directory  name.   Subdirectories
  358.    with  common parents will be listed in aplhabetical order.   A
  359.    pointer  (in  red on a color display) will indicate  the  cur-
  360.    rently  logged-in  directory,  and (on a  color  display)  the
  361.    directories with matches will appear in green while all others
  362.    will  appear in yellow.   This mode is limited to displaying 5
  363.    levels of a directory structure because of the 80 column limit
  364.    of the screen.   However,  as many levels as are necessary may
  365.    be displayed by starting the display at a lower level than the
  366.    root.  This option defaults off.
  367.  
  368.    U - Unsorted
  369.  
  370.      When this option is switched on,  TD will perform no sorting
  371.    of directories or files.  TD's sorting is fast enough for most
  372.    purposes.  However, when cataloging large disks, the directory
  373.    information  may be taken in an unsorted form and the  sorting
  374.    task  deferred for the data manager.   This will speed up  the
  375.    capturing of entries somewhat,  although the real limit to the
  376.    process is the slow speed of DOS's redirectable output.   This
  377.    option defaults off.
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.                                 6
  391.  
  392.  
  393.  
  394.  
  395.  
  396.                    TD - A Tree Directory Tool
  397.  
  398.  
  399.  
  400.  
  401.    V - Volume name change
  402.  
  403.      When  this option is switched on,  TD will prompt for a  new
  404.    volume name.   If no name exists,  one may be added.  Pressing
  405.    the  return  key in response to the prompt will leave the  old
  406.    name  intact.   Note that DOS's rules on volume names are  not
  407.    enforced by TD.   This makes things a bit more  flexible,  but
  408.    taking advantage of this flexibility (for instance,  including
  409.    spaces in volume names) may cause trouble with other programs.
  410.    Names  are restricted to 11 characters.   This option defaults
  411.    off.
  412.  
  413.    W - Wide listing
  414.  
  415.      When this option is switched on,  TD will restrict its list-
  416.    ing  to blocks of filenames and extensions,  where each  block
  417.    represents a directory.  The directory blocks are presented in
  418.    alphabetical order of directory name, and the files within the
  419.    blocks  will  appear according to the currently-selected  sort
  420.    mode.  From the command line, this is the most convenient mode
  421.    to use with TD.   It allows more information on the screen and
  422.    operates  faster than the full listing (default)  mode.   This
  423.    option defaults off.
  424.  
  425.    X - eXclude other directories
  426.  
  427.      When  this option is switched on,  TD will stop looking  for
  428.    files  after it has finished looking through the directory  it
  429.    started looking in.  This is included to keep TD from churning
  430.    through  all  the directories on a disk when it  is  known  in
  431.    advance that the search should be restricted to one directory.
  432.    It  is also useful in speeding up TD's operation in situations
  433.    where  only  the environment variables are of interest (as  in
  434.    the batch file shown in the section on batch variables).  This
  435.    option defaults off.
  436.  
  437.    2, 3 - dBASE II or III SDF
  438.  
  439.      If  either of these options is switched on,  TD will  format
  440.    its output to be suitable for direct pick-up with the dBASE II
  441.    or  dBASE III data base management programs from  Ashton-Tate.
  442.    Please  see the section on using TD as a tool  for  cataloging
  443.    files for a complete discussion.  This option defaults off.
  444.  
  445.    ? - help
  446.  
  447.      Selecting this option will cause TD to present a help screen
  448.    listing the switch options supported.
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.                                 7
  457.  
  458.  
  459.  
  460.  
  461.  
  462.                    TD - A Tree Directory Tool
  463.  
  464.  
  465.  
  466.  
  467. 4.  Using TD as a tool for cataloging files:
  468.  
  469.   TD's  default  redirectable ASCII output may be picked up  with
  470. dBASE (or other general purpose file handlers) to create a useful
  471. master  catalog.   An example of this master catalog  application
  472. may be had by starting TD with the following command line:
  473.  
  474.                     td b:\/cah2>>catalog.txt
  475.  
  476.   This  will cause the repeated listing of all files at or  below
  477. the root level for any diskettes placed in drive B.   Additional-
  478. ly,  the  switch  settings shown in the example  will  cause  the
  479. program  to prompt for a volume name for each diskette which does
  480. not  already  have a name,  and to include any system  or  hidden
  481. files in the directory listing.   Because the "2" switch is used,
  482. the  directory listings in the "catalog.txt" file will be  in  an
  483. SDF  format  suitable  for direct pick up with a  dBASE  II  file
  484. having the following fields:
  485.  
  486.                       VOL:PATH   C  37
  487.                       NAME       C   8
  488.                       EXT        C   3
  489.                       SIZE       N   8
  490.                     * DATE       C   8
  491.                       TIME       C   8
  492.  
  493.   ( * make this a D field with dBASE III and use the /3 switch )
  494.  
  495.   The loading of the data into dBASE is done with the command:
  496.  
  497.                   append from catalog.txt sdf
  498.  
  499.   This will load the dBASE file with the directory entries.  This
  500. allows  the full power of dBASE to be used in identifying  dupli-
  501. cate files and out-of-date copies of data or source code.
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.                                 8
  523.  
  524.  
  525.  
  526.  
  527.  
  528.                    TD - A Tree Directory Tool
  529.  
  530.  
  531.  
  532.  
  533. 5.  Use of TD in place of DIR:
  534.  
  535.   TD  may be used in place of DIR,  gaining the ability to search
  536. an entire disk for files with just one command.   Here are a  few
  537. examples:
  538.  
  539.   COMMAND             RESULTING LISTING
  540.   -------             -----------------
  541.   td                  Files on current drive at or below the current
  542.                         directory (no hidden or system files will be
  543.                         shown, the output will be sorted within each
  544.                         directory by file name, and the output will
  545.                         pause at each full screen).  Note, this may
  546.                         be overridden by a option string stored in the
  547.                         DOS environment as explained below.
  548.   td \                Files on current drive at or below the root
  549.   td \/w              All files, but just the names and extensions
  550.   td \/t              All directories, in tree format
  551.   td \/p              All files, but with no pause at full screens
  552.   td  \/q             Environment  variables  only,  no  screen output
  553.   td /x               Files in the current directory
  554.   td ??/x             Files with one or two-character names in the current
  555.                         directory
  556.   td td               Files at or below the current directory which match
  557.                         td.*
  558.   td b:\.com          COM files on B:
  559.   td b:\util\/x       Files in B:'s UTIL directory
  560.   td b:\util\.com     COM files in or below B:'s UTIL directory
  561.   td \.doc/ql         Logs the current drive into the last
  562.                         directory which holds a *.DOC file
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.                                 9
  589.  
  590.  
  591.  
  592.  
  593.  
  594.                    TD - A Tree Directory Tool
  595.  
  596.  
  597.  
  598.  
  599. 6.  TD's use of the DOS environment for options:
  600.  
  601.   Typing  TD's  frequently used command line options  can  become
  602. tedious.   So, TD takes advantage of the DOS environment to store
  603. a  string  of default command line  options.   These  environment
  604. options  provide  a  convenient way to indefinitely  modify  TD's
  605. behavior.  Until  they are cancelled,  the options stored in  the
  606. environment will be used in place of, or in addition to, whatever
  607. is  typed  on the command line when TD is started.   To  set  the
  608. environment options,  use the DOS SET command.  The format is SET
  609. TD=[/options].  For example:
  610.  
  611.                           SET TD=b:/th.
  612.  
  613.   This  set of options will cause TD to give a pictorial tree  of
  614. the disk in the B: drive, listing system, hidden and normal files
  615. whenever "td" is typed.
  616.  
  617.   TD  will append the environment options to options typed in  on
  618. the command line if the first character of the environment option
  619. string is a "+".  For example:
  620.  
  621.                           SET TD=+/wha.
  622.  
  623.   This set of options (which I set in my AUTOEXEC.BAT file)  will
  624. be  appended  to whatever is typed in on the command  line.   So,
  625. typing  "td  b:"  will cause TD to give a  wide  listing  of  B:,
  626. showing  hidden,  system  and normal files,  and prompting for  a
  627. volume name if none exists.   Because the environment options are
  628. appended to the command line options,  some program behavior will
  629. only be available after clearing the options in the  environment.
  630. To do this type  "SET TD="
  631.  
  632.   Remember  that DOS sets aside only a small environment area  at
  633. boot  time.   If problems are experienced using  the  environment
  634. options the environment is probably full.   If the environment is
  635. full,  either  some  variables  (or overly long  PATH  or  PROMPT
  636. strings)  must be eliminated or the environment must be expanded.
  637.  
  638. 7.  Restrictions:
  639.  
  640.   TD's  output format is designed for 80 column  displays.   This
  641. limits  the  total  number of characters which  may  be  properly
  642. displayed from the combined volume and name path to 37.   It also
  643. limits  the properly formatted display of "trees" to a  depth  of
  644. five levels.
  645.  
  646. 8.  Contradictions:
  647.  
  648.   If  contradictory switch settings are specified on the  command
  649. line  (for  example,  two sort methods) then  the  last-specified
  650. setting will be used.
  651.  
  652.  
  653.  
  654.                                10
  655.